using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using BLL.BusinessLayer.DataLayer;

namespace BLL.BusinessLayer
{
    public class ClsTest_QuestionFactory
    {

        #region data Members

        ClsTest_QuestionSql _dataObject = null;

        #endregion

        #region Constructor

        public ClsTest_QuestionFactory()
        {
            _dataObject = new ClsTest_QuestionSql();
        }

        #endregion


        #region Public Methods

        /// <summary>
        /// Insert new ClsTest_Question
        /// </summary>
        /// <param name="businessObject">ClsTest_Question object</param>
        /// <returns>true for successfully saved</returns>
        public bool Insert(ClsTest_Question businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Insert(businessObject);

        }

        /// <summary>
        /// Update existing ClsTest_Question
        /// </summary>
        /// <param name="businessObject">ClsTest_Question object</param>
        /// <returns>true for successfully saved</returns>
        public bool Update(ClsTest_Question businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Update(businessObject);
        }
/// <summary>
        /// Update existing ClsTest_Question
        /// </summary>
        /// <param name="businessObject">ClsTest_Question object</param>
        /// <returns>true for successfully saved</returns>
        public bool RunSQLSP(string strSQL)
        {

            return _dataObject.RunSQL(strSQL);
        }


        /// <summary>
        /// get ClsTest_Question by primary key.
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>Student</returns>
        public ClsTest_Question GetByPrimaryKey(ClsTest_QuestionKeys keys)
        {
            return _dataObject.SelectByPrimaryKey(keys); 
        }

        /// <summary>
        /// get list of all ClsTest_Questions
        /// </summary>
        /// <returns>list</returns>
        public List<ClsTest_Question> GetAll()
        {
            return _dataObject.SelectAll(); 
        }

        /// <summary>
        /// get list of all ClsTest_Questions
        /// </summary>
        /// <returns>list</returns>
        public DataSet GetAllToDataSet()
        {
            return _dataObject.GetAllToDataSet(); 
        }

        /// <summary>
        /// get list of ClsTest_Question by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public List<ClsTest_Question> GetAllBy(ClsTest_Question.ClsTest_QuestionFields fieldName, object value)
        {
            return _dataObject.SelectByField(fieldName.ToString(), value);  
        }
        /// <summary>
        /// Lấy về danh sách ClsTest_Question by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectByFieldToDataSet (ClsTest_Question.ClsTest_QuestionFields fieldName, object value)
        {
            return _dataObject.SelectByFieldToDataSet(fieldName.ToString(), value);  
        }
        /// <summary>
        /// Lấy về danh sách ClsTest_Question by Sql
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectSqlToDataTable (string strSql)
        {
            return _dataObject.SelectSqlToDataTable(strSql);  
        }

/// <summary>
        /// Lấy về danh sách ClsTest_Question by Sql
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectTableByWhereSql (string strWhere)
        {
            return _dataObject.SelectTableByWhereSql(strWhere);  
        }
        /// <summary>
        /// delete by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>true for succesfully deleted</returns>
        public bool Delete(ClsTest_QuestionKeys keys)
        {
            return _dataObject.Delete(keys); 
        }

        /// <summary>
        /// delete ClsTest_Question by field.
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(ClsTest_Question.ClsTest_QuestionFields fieldName, object value)
        {
            return _dataObject.DeleteByField(fieldName.ToString(), value); 
        }

        #endregion

    }
}
